import { http } from "@/utils/http";
import type { GetOrderInfoResponse, PayParams } from "./types";

/**
 * 添加订单
 * @param courseId 课程id
 * @returns orderId
 */
export const addOrderApi = (courseId: string) => {
  return http.post<{
    orderId: string;
  }>(`/api/order/auth/save/${courseId}`);
};

/**
 * 获取订单信息
 * @param orderId 订单id
 * @returns GetOrderInfoResponse
 */
export const getOrderInfoApi = (orderId: string) => {
  return http.get<GetOrderInfoResponse>(`/api/order/auth/get/${orderId}`);
};

/**
 * 获取订单支付参数
 * @param orderNo 订单编号
 * @returns PayParams
 */
export const getOrderPayParamsApi = (orderNo: string) => {
  return http.get<PayParams>(`/api/order/webChat/createJsapi/${orderNo}`);
};
